package com.entity;

import java.io.Serializable;
import javax.persistence.*;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.alibaba.fastjson.annotation.JSONField;

import java.math.BigDecimal;
import java.util.List;

/**
 * The persistent class for the PRODUCT database table.
 * 
 */
@Entity
@NamedQuery(name = "Product.findAll", query = "SELECT p FROM Product p")
public class Product implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name = "PRODUCT_ID_GENERATOR", sequenceName = "SEQ", initialValue = 1, allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PRODUCT_ID_GENERATOR")
	private Long id;

	private String code;

	private BigDecimal cost;

	private Boolean isstock;

	@Column(name = "JD_CODE")
	private String jdCode;

	@Column(name = "LOWER_STOCK")
	private BigDecimal lowerStock;

	private String model;

	private String name;

	private String outline;

	private BigDecimal price;

	@Column(name = "PRICESTRATEGY_ID")
	private BigDecimal pricestrategyId;


	@Column(name="\"PRIVILEGEGROUP_ID\"")
	private BigDecimal privilegeGroup_id;

	private BigDecimal serial;

	private Boolean status;

	@Column(name = "TB_CODE")
	private String tbCode;

	@Column(name = "TM_CODE")
	private String tmCode;

	@Column(name = "UNIT_ID")
	private BigDecimal unitId;

	@Column(name = "UPPER_STOCK")
	private BigDecimal upperStock;

	private BigDecimal weight;

	// bi-directional many-to-one association to Pricestrategy
	@OneToMany(mappedBy = "product")
	@JSONField(serialize = false)
	private List<Pricestrategy> pricestrategies;


	//bi-directional many-to-one association to Purchase
	@ManyToOne(cascade={CascadeType.PERSIST,CascadeType.MERGE})
	@JoinColumn(name="PURCHASE_ID")
	private Purchase purchase;


	//bi-directional many-to-one association to ProductClassify
//	@OneToMany(mappedBy="product")
	@ManyToOne(cascade={CascadeType.PERSIST,CascadeType.MERGE})
	@JoinColumn(name="CLASSIFY_ID")
	@NotFound(action=NotFoundAction.IGNORE)
	private ProductClassify productClassify;

	// bi-directional many-to-one association to ProductStandard
	@OneToMany(mappedBy = "product")
	@JSONField(serialize = false)
	private List<ProductStandard> productStandards;

	// bi-directional many-to-one association to Repairorder
	@OneToMany(mappedBy = "product")
	@JSONField(serialize = false)
	private List<Repairorder> repairorders;

	// bi-directional many-to-one association to Unit
	@OneToMany(mappedBy = "product")
	@JSONField(serialize = false)
	private List<Unit> units;

	// bi-directional many-to-one association to Product
	@OneToMany(mappedBy = "product")
	@JSONField(serialize = false)
	private List<Offerdetail> offerdetails;

	// bi-directional many-to-many association to Order
	@ManyToMany(mappedBy = "products")
	@JSONField(serialize = false)
	private List<Order> orders;

	
	@OneToMany(mappedBy = "product")
	@JSONField(serialize =false)
	private List<Deliver> delivers;
	
	

	public List<Deliver> getDelivers() {
		return delivers;
	}

	public void setDelivers(List<Deliver> delivers) {
		this.delivers = delivers;
	}

	public Product() {
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getCode() {
		return this.code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public BigDecimal getCost() {
		return this.cost;
	}

	public void setCost(BigDecimal cost) {
		this.cost = cost;
	}

	public Boolean getIsstock() {
		return this.isstock;
	}

	public void setIsstock(Boolean isstock) {
		this.isstock = isstock;
	}

	public String getJdCode() {
		return this.jdCode;
	}

	public void setJdCode(String jdCode) {
		this.jdCode = jdCode;
	}

	public BigDecimal getLowerStock() {
		return this.lowerStock;
	}

	public void setLowerStock(BigDecimal lowerStock) {
		this.lowerStock = lowerStock;
	}

	public String getModel() {
		return this.model;
	}

	public void setModel(String model) {
		this.model = model;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getOutline() {
		return this.outline;
	}

	public void setOutline(String outline) {
		this.outline = outline;
	}

	public BigDecimal getPrice() {
		return this.price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	public BigDecimal getPricestrategyId() {
		return this.pricestrategyId;
	}

	public void setPricestrategyId(BigDecimal pricestrategyId) {
		this.pricestrategyId = pricestrategyId;
	}

	public BigDecimal getPrivilegeGroup_id() {
		return this.privilegeGroup_id;
	}

	public void setPrivilegeGroup_id(BigDecimal privilegeGroup_id) {
		this.privilegeGroup_id = privilegeGroup_id;
	}

	public BigDecimal getSerial() {
		return this.serial;
	}

	public void setSerial(BigDecimal serial) {
		this.serial = serial;
	}

	public Boolean getStatus() {
		return this.status;
	}

	public void setStatus(Boolean status) {
		this.status = status;
	}

	public String getTbCode() {
		return this.tbCode;
	}

	public void setTbCode(String tbCode) {
		this.tbCode = tbCode;
	}

	public String getTmCode() {
		return this.tmCode;
	}

	public void setTmCode(String tmCode) {
		this.tmCode = tmCode;
	}

	public BigDecimal getUnitId() {
		return this.unitId;
	}

	public void setUnitId(BigDecimal unitId) {
		this.unitId = unitId;
	}

	public BigDecimal getUpperStock() {
		return this.upperStock;
	}

	public void setUpperStock(BigDecimal upperStock) {
		this.upperStock = upperStock;
	}

	public BigDecimal getWeight() {
		return this.weight;
	}

	public void setWeight(BigDecimal weight) {
		this.weight = weight;
	}

	public List<Pricestrategy> getPricestrategies() {
		return this.pricestrategies;
	}

	public void setPricestrategies(List<Pricestrategy> pricestrategies) {
		this.pricestrategies = pricestrategies;
	}

	public Pricestrategy addPricestrategy(Pricestrategy pricestrategy) {
		getPricestrategies().add(pricestrategy);
		pricestrategy.setProduct(this);

		return pricestrategy;
	}

	public Pricestrategy removePricestrategy(Pricestrategy pricestrategy) {
		getPricestrategies().remove(pricestrategy);
		pricestrategy.setProduct(null);

		return pricestrategy;
	}

	public Purchase getPurchase() {
		return this.purchase;
	}

	public void setPurchase(Purchase purchase) {
		this.purchase = purchase;
	}

	public ProductClassify getProductClassify() {
		return this.productClassify;
	}

	public void setProductClassify(ProductClassify productClassify) {
		this.productClassify = productClassify;
	}

	/*
	 * public ProductClassify addProductClassify(ProductClassify productClassify) {
	 * getProductClassifies().add(productClassify);
	 * productClassify.setProduct(this);
	 * 
	 * return productClassify; }
	 * 
	 * public ProductClassify removeProductClassify(ProductClassify productClassify)
	 * { getProductClassifies().remove(productClassify);
	 * productClassify.setProduct(null);
	 * 
	 * return productClassify; }
	 */

	public List<ProductStandard> getProductStandards() {
		return this.productStandards;
	}

	public void setProductStandards(List<ProductStandard> productStandards) {
		this.productStandards = productStandards;
	}

	public ProductStandard addProductStandard(ProductStandard productStandard) {
		getProductStandards().add(productStandard);
		productStandard.setProduct(this);

		return productStandard;
	}

	public ProductStandard removeProductStandard(ProductStandard productStandard) {
		getProductStandards().remove(productStandard);
		productStandard.setProduct(null);

		return productStandard;
	}

	public List<Repairorder> getRepairorders() {
		return this.repairorders;
	}

	public void setRepairorders(List<Repairorder> repairorders) {
		this.repairorders = repairorders;
	}

	public Repairorder addRepairorder(Repairorder repairorder) {
		getRepairorders().add(repairorder);
		repairorder.setProduct(this);

		return repairorder;
	}

	public Repairorder removeRepairorder(Repairorder repairorder) {
		getRepairorders().remove(repairorder);
		repairorder.setProduct(null);

		return repairorder;
	}

	public List<Unit> getUnits() {
		return this.units;
	}

	public void setUnits(List<Unit> units) {
		this.units = units;
	}

	public Unit addUnit(Unit unit) {
		getUnits().add(unit);
		unit.setProduct(this);

		return unit;
	}

	public Unit removeUnit(Unit unit) {
		getUnits().remove(unit);
		unit.setProduct(null);

		return unit;
	}

	public List<Order> getOrders() {
		return this.orders;
	}

	public void setOrders(List<Order> orders) {
		this.orders = orders;
	}

	public List<Offerdetail> getOfferdetails() {
		return offerdetails;
	}

	public void setOfferdetails(List<Offerdetail> offerdetails) {
		this.offerdetails = offerdetails;
	}

	public Offerdetail addOfferdetail(Offerdetail offerdetail) {
		getOfferdetails().add(offerdetail);
		offerdetail.setProduct(this);

		return offerdetail;
	}

	public Offerdetail removeOfferdetail(Offerdetail offerdetail) {
		getOfferdetails().add(offerdetail);
		offerdetail.setProduct(null);

		return offerdetail;
	}

}